package cn.xm.test3.exception;


public enum ErroCode {

    PASSWORD_CHECK_FAILED("1003","密码校验失败"),
    CONTENT_AUDIT_FAILED("1004","内容审核失败"),
    IMAGE_CODE_TIME_OUT("1005","图形验证码已过期"),
    IMAGE_CODE_ERROR("1006","图形验证码错误"),
    PAGE_ERROR("1002","分页错误");

    private String code;
    private String message;

    ErroCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErroCode getByCode(String code) {
        // 获取此枚举的所有对象
        ErroCode[] values = ErroCode.values();
        // 找到传入code对应的枚举对象
        for (ErroCode erroCode : values) {
            if (erroCode.getCode().equals(code)) {
                return erroCode;
            }
        }
        return null;
    }
}
